﻿using System.Web.Mvc;

namespace WebStickyNotes.Helpers
{
    public class MustSignInAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (!SecurityHelper.IsSignedIn())
            {
                filterContext.Result = new RedirectToRouteResult(
                    new System.Web.Routing.RouteValueDictionary
                        {
                            {"controller", "SignIn"},
                            {"action", "Index"}
                        }
                    );

            }

            base.OnActionExecuting(filterContext);
        }

    }
}